<template>
  <div class="Dialog">
    <div class="Dialog--Tips">
      <div class="Dialog--Tips__img">
        <img :src="this.img.prodImage[0]" alt="">
      </div>
      <div class="Dialog--Tips__img--text">
        <span class="money">￥{{this.img.currentPrice}}</span><br>
        <span class="CommodityNumber">商品编号:{{this.img._id}}</span>
      </div>
      <div class="Dialog--Tips--number">
        <div class="Dialog--Tips--number_num">
          <span>数量</span>
          <span class="subtraction" @click="subtrAction">
            <img src="../assets/subtraction.png" alt="">
          </span>
          <span class="num">{{num}}</span>
          <span class="Addition" @click="add">
            <img src="../assets/add.png" alt="">
          </span>
        </div>
      </div>
      <div class="Dialog--footer" @click="go">确定</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ShoppingCart--Dialog",
  data() {
    return {
      img: [],
      xxx: [],
      num: 1,
      Price: '',
    }
  },
  methods: {
    subtrAction() {
      if (this.num > 1) {
        this.num--;
        this.img.currentPrice = this.Price * this.num;
      }
    },
    add(){
     this.num++;
     this.img.currentPrice = this.Price * this.num;
    },
    go(){
      this.$apis.shoppingCart({
        prodid: this.xxx._id,
        num: this.num,
      })
        .then(data => {
          console.log(data);
        })
        .catch(error => {
          console.log(error);
        });
      this.show = false;
      this.$Bus.$emit('w');
    }
  },
  created() {
    this.$Bus.$on('x', (data) => {
    this.xxx = data;
    });
    this.img = this.$route.params.data;
    console.log(this.img);
    this.Price = this.$route.params.data.currentPrice;
  }
}
</script>

<style scoped>
  .Dialog{
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0, .5);
    position: fixed;
    z-index: 999;
  }
  .Dialog--Tips{
    width: 100vw;
    height: 962px;
    background: white;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
  }
  .Dialog--Tips__img{
    width: 220px;
    height: 220px;
    border-radius: 5px;
    position: relative;
    left: 30px;
    top: -68px;
    box-shadow: 1px 1px 1px #999;
  }
  .Dialog--Tips__img>img{
    display: inline-block;
    width: 220px;
    height: 220px;
    border-radius: 5px;
  }
  .Dialog--Tips__img--text{
    display: inline-block;
    position: relative;
    width: 460px;
    height: 155px;
    left: 273px;
    top: -220px;
  }
  .money{
    display: inline-block;
    position: relative;
    font-size: 30px;
    color: #ff3202;
    line-height: 60px;
    left: 17px;
  }
  .CommodityNumber{
    font-size: 26px;
    color: #333333;
    display: inline-block;
    position: relative;
    left: 17px;
  }
  .Dialog--Tips--number{
    width: 693px;
    height: 300px;
    position: relative;
    left: 30px;
    border-top: 1px solid #ddd;
    top: -160px;
  }
  .Dialog--Tips--number_num{
    display: inline-block;
    color: #434343;
    font-size: 30px;
    line-height: 100px;
  }
  .subtraction{
    display: inline-block;
    position: relative;
    width: 60px;
    height: 60px;
    border: 1px solid #bbb;
    top: 21px;
    left: 34px;
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
  }
  .subtraction>img{
    display: inline-block;
    position: relative;
    width: 30px;
    top: -15px;
    left: 15px;
  }
  .num{
    display: inline-block;
    position: relative;
    font-size: 24px;
    text-align: center;
    width: 83px;
    left: 26px;
    line-height: 60px;
    border: 1px solid #bbb;
  }
  .Addition{
    display: inline-block;
    position: relative;
    width: 60px;
    height: 60px;
    border: 1px solid #bbb;
    top: 21px;
    left: 16px;
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
  }
  .Addition>img{
    display: inline-block;
    position: relative;
    width: 30px;
    top: -15px;
    left: 15px;
  }
  .Dialog--footer{
    width: 100vw;
    color: white;
    background: #3d9dfd;
    text-align: center;
    line-height: 91px;
    position: absolute;
    font-size: 35px;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
  }
</style>
